home *** CD-ROM | disk | FTP | other *** search
/ BCI NET 2 / BCI NET 2.iso / archives / programming / c / hce.lha / HCE / LibSource / AmigaLib / EXTRAS / Source / CreatePort.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-09-02  |  819 b   |  36 lines

  1. #include <exec/types.h>
  2. #include <exec/ports.h>
  3. #include <exec/memory.h>
  4.  
  5. struct MsgPort *CreatePort (name, pri)
  6. char *name;
  7. LONG pri;
  8. {
  9.      int sigBit;
  10.      struct MsgPort *port;
  11.  
  12.      if ((sigBit = AllocSignal(-1L)) == -1)
  13.           return (NULL);
  14.  
  15.    port = (struct MsgPort *)
  16.     AllocMem((ULONG)sizeof(struct MsgPort), (ULONG)MEMF_CLEAR|MEMF_PUBLIC);
  17.  
  18.      if (!port) {
  19.           FreeSignal (sigBit);
  20.           return(NULL);
  21.           }
  22.  
  23.          port->mp_Node.ln_Name = name;
  24.          port->mp_Node.ln_Pri = pri;
  25.          port->mp_Node.ln_Type = NT_MSGPORT;
  26.          port->mp_Flags = PA_SIGNAL;
  27.          port->mp_SigBit = sigBit;
  28.          port->mp_SigTask = (void *)FindTask (0L);
  29.          if (name)
  30.               AddPort (port);
  31.          else
  32.               NewList (&(port->mp_MsgList));
  33.  
  34.      return (port);
  35. }
  36.